import Singleton from "../net/Singleton";
import LogUtil from "../utils/LogUtil";
import ResManager from "./ResManager";

/** 语言表管理 */
export default class LanguageManager extends Singleton {
    getString(_key) {
        let _lang = ResManager.ins().getRes('config_language');
        if (!_lang) {
            LogUtil.warn('未读取语言表');
            return _key;
        } else {
            if (!_lang[_key]) {
                LogUtil.warn('未找到关键字', _key);
                return _key;
            } else {
                let text =  _lang[_key].text.replace(/\\n/g, '\n');
                return text;
            }
        }
    }
}